package com.csd.activity;

import com.csd.view.TimePopupwindow;

import android.app.ActionBar;
import android.app.Activity;
import android.app.ActionBar.LayoutParams;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MoreRecoderActivity extends Activity implements OnClickListener{

	private LinearLayout ll_more,ll_detail;
	private Button bt_query;
	private ImageView img_start,img_end;
	private TextView tv_start,tv_end;
	private ActionBar actionBar;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_morerecord);
		initView();
		initActionBar();
	}
	private void initView() {
		// TODO Auto-generated method stub
		ll_more = (LinearLayout) findViewById(R.id.more);
		bt_query = (Button) findViewById(R.id.query);
		bt_query.setOnClickListener(this);
		img_start = (ImageView) findViewById(R.id.start);
		img_end = (ImageView) findViewById(R.id.end);
		img_start.setOnClickListener(this);
		img_end.setOnClickListener(this);
		tv_start = (TextView) findViewById(R.id.start_time);
		tv_end = (TextView) findViewById(R.id.end_time);
		ll_detail = (LinearLayout) findViewById(R.id.detail);
		ll_detail.setOnClickListener(this);
	}
	
	private void initActionBar() {
		// TODO Auto-generated method stub
		actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(false);
		actionBar.setDisplayShowHomeEnabled(false);
		actionBar.setDisplayShowTitleEnabled(false);
		actionBar.setDisplayShowCustomEnabled(true);

		LayoutInflater inflator = (LayoutInflater) getSystemService(this.LAYOUT_INFLATER_SERVICE);

		View v = inflator.inflate(R.layout.actionbar_main, null);
		TextView title = (TextView) v.findViewById(R.id.title);
		title.setText("查询交易记录");
		ImageView img = (ImageView) v.findViewById(R.id.logo);
		img.setImageDrawable(getResources().getDrawable(R.drawable.u86));
		img.setOnClickListener(this);
		ActionBar.LayoutParams layout = new ActionBar.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		actionBar.setCustomView(v, layout);

	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.query:
			ll_more.setVisibility(View.VISIBLE);
			break;
		case R.id.start:
			TimePopupwindow takeTime = new TimePopupwindow(this,
					tv_start);
			takeTime.showPopupWindow(img_start);

			break;
		case R.id.end:
			TimePopupwindow takeTime1 = new TimePopupwindow(this,
					tv_end);
			takeTime1.showPopupWindow(img_end);
			break;
		case R.id.detail:
			Intent intent = new Intent(this, PersonalDetailActivity.class);
			startActivity(intent);
			break;
		case R.id.logo:
			finish();
			break;
		default:
			break;
		}
	}
}
